package com.qingzhuge.mq.producer.activemq;

import com.qingzhuge.mq.IProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;

import javax.jms.Queue;
import javax.jms.Topic;

/**
 * @author : zero.xiao
 * @description : ActiveMQ 提供消息
 * @date :2019-06-19 10:34
 * @modified :
 */
@Slf4j
public class ProducerActiveMq implements IProducer {

    @Autowired
    private JmsMessagingTemplate messagingTemplate;

    @Override
    public <M> void sendMessage(String topic, M msg) {
        messagingTemplate.convertAndSend(topic, msg);
        log.debug("activeMQ send topic:{},msg:{}", topic, msg);
    }

    @Override
    public <M> void sendMessage(Topic topic, M msg) {
        messagingTemplate.convertAndSend(topic, msg);
        log.debug("activeMQ send topic:{},msg:{}", topic, msg);
    }

    @Override
    public <M> void sendMessage(Queue queue, M msg) {
        messagingTemplate.convertAndSend(queue, msg);
        log.debug("activeMQ send queue:{},msg:{}", queue, msg);
    }
}
